Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Human Review Client Endpoints #211

Merged
merged 5 commits into from
Sep 22, 2024
Merged

Conversation

adamnolte
Copy link
Contributor

@adamnolte adamnolte commented Sep 22, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new interfaces for managing human review jobs, including HumanReviewJob, HumanReviewJobWithTestCases, and HumanReviewJobTestCaseResult.
    • Added methods to retrieve human review jobs and their associated test cases and results.
  • Enhancements

    • Expanded type exports to include new human review-related types for better integration and usage.
    • Added a new enumeration for HumanReviewFieldContentType, defining content types like TEXT, MARKDOWN, HTML, and LINK.
  • Refactor

    • Updated the source of HumanReviewFieldContentType to streamline type management across modules.

Copy link

coderabbitai bot commented Sep 22, 2024

Walkthrough

Walkthrough

The changes introduce new interfaces and methods in the src/client.ts file to manage human review jobs, including retrieving job details and test case results. Additionally, the exports in src/index.ts are updated to include new types related to human review, and the HumanReviewFieldContentType enum is added to src/types.ts. The structure of exports is also modified in src/testing/index.ts and src/testing/models.ts to reflect these updates.

Changes

Files Change Summary
src/client.ts Added interfaces: HumanReviewJob, HumanReviewJobWithTestCases, HumanReviewJobTestCaseResult. Added methods: getHumanReviewJobs, getTestCasesForHumanReviewJob, getTestCaseResultForHumanReviewJob.
src/index.ts Expanded type exports to include HumanReviewJob, HumanReviewJobWithTestCases, HumanReviewJobTestCaseResult, and updated HumanReviewFieldContentType export.
src/testing/index.ts Updated export source for HumanReviewFieldContentType from ./models to ../types.
src/testing/models.ts Removed local declaration of HumanReviewFieldContentType enum and imported it from ../types.
src/types.ts Introduced a new enum HumanReviewFieldContentType with members: TEXT, MARKDOWN, HTML, and LINK.

Possibly related issues

  • EPD-1395: The changes add API endpoints to retrieve human review data, which aligns with the objective of this issue.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6266f8c and 41b7236.

Files selected for processing (1)
  • src/client.ts (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/client.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b60d3a9 and a2fe5ad.

Files selected for processing (5)
  • src/client.ts (3 hunks)
  • src/index.ts (1 hunks)
  • src/testing/index.ts (1 hunks)
  • src/testing/models.ts (1 hunks)
  • src/types.ts (1 hunks)
Additional comments not posted (7)
src/index.ts (2)

4-11: LGTM!

The export statement is syntactically correct and aligns with the changes mentioned in the AI-generated summary. The additional type exports enhance the type definitions available for import from index.ts.


12-12: LGTM!

The export statement is syntactically correct and aligns with the changes mentioned in the AI-generated summary. The additional type export enhances the type definitions available for import from index.ts.

src/types.ts (1)

45-51: LGTM!

The new HumanReviewFieldContentType enum is a valuable addition that enables type-safe handling of different content types in the context of human review processes. The enum provides a structured way to represent and work with various content formats.

The enum follows good naming conventions, with uppercase constants. It is properly exported, making it available for use in other parts of the codebase.

Overall, the addition of this enum enhances the type definitions and does not introduce any breaking changes or negative impacts on existing code.

src/testing/index.ts (1)

16-16: LGTM!

The change updates the export source for HumanReviewFieldContentType from ./models to ../types. This aligns with the alterations mentioned in the summary and should not have any negative impact on the functionality or usage of the exported entity.

src/testing/models.ts (1)

2-2: LGTM!

Moving the HumanReviewFieldContentType enum to a central location in ../types is a good practice to promote reusability and avoid duplication across the codebase.

src/client.ts (2)

72-76: Interfaces for Human Review Jobs are well-defined

The HumanReviewJob interface is appropriately structured.


78-81: Extension of HumanReviewJob with Test Cases

The HumanReviewJobWithTestCases interface correctly extends HumanReviewJob and adds the testCases property.

src/client.ts Outdated
Comment on lines 82 to 123
export interface HumanReviewJobTestCaseResult {
id: string;
reviewerEmail: string;
status: 'Submitted' | 'Pending';
grades: { name: string; grade: number }[];
automatedEvaluations: {
id: string;
originalScore: number;
overrideScore: number;
overrideReason?: string;
}[];
inputFields: {
id: string;
name: string;
value: string;
contentType: HumanReviewFieldContentType;
}[];
outputFields: {
id: string;
name: string;
value: string;
contentType: HumanReviewFieldContentType;
}[];
fieldComments: {
fieldId: string;
startIdx?: number;
endIdx?: number;
value: string;
inRelationToGradeName?: string;
inRelationToAutomatedEvaluationId?: string;
}[];
inputComments: {
value: string;
inRelationToGradeName?: string;
inRelationToAutomatedEvaluationId?: string;
}[];
outputComments: {
value: string;
inRelationToGradeName?: string;
inRelationToAutomatedEvaluationId?: string;
}[];
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent representation of reviewer information

In HumanReviewJob, the reviewer is represented as an object with id and email:

reviewer: { id: string; email: string };

However, in HumanReviewJobTestCaseResult, the reviewer is represented by a single reviewerEmail string property:

reviewerEmail: string;

For consistency and future extensibility, consider representing the reviewer in HumanReviewJobTestCaseResult as an object similar to HumanReviewJob.

Comment on lines +232 to +234
public async getHumanReviewJobs(): Promise<{ jobs: HumanReviewJob[] }> {
return this.get('/human-review/jobs');
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider consistent return types for methods

The getHumanReviewJobs method returns Promise<{ jobs: HumanReviewJob[] }>, wrapping the array in an object. However, other methods like getViews() return arrays directly as Promise<View[]>.

For consistency, consider returning Promise<HumanReviewJob[]> directly, unless the API response necessitates the wrapping object.

src/client.ts Outdated
Comment on lines 232 to 247
public async getHumanReviewJobs(): Promise<{ jobs: HumanReviewJob[] }> {
return this.get('/human-review/jobs');
}

public async getHumanReviewJobTestCases(
jobId: string,
): Promise<HumanReviewJobWithTestCases> {
return this.get(`/human-review/jobs/${jobId}/test-cases`);
}

public async getHumanReviewJobTestCaseResult(
jobId: string,
testCaseId: string,
): Promise<HumanReviewJobTestCaseResult> {
return this.get(`/human-review/jobs/${jobId}/test-cases/${testCaseId}`);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add unit tests for new API methods

Consider adding unit tests for the newly added methods to ensure they function correctly and handle potential errors.

src/client.ts Outdated
Comment on lines 236 to 240
public async getHumanReviewJobTestCases(
jobId: string,
): Promise<HumanReviewJobWithTestCases> {
return this.get(`/human-review/jobs/${jobId}/test-cases`);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper encoding of jobId in URL

When constructing the URL in getHumanReviewJobTestCases, consider encoding jobId to handle any special characters that may be present.

Apply this diff to encode the jobId:

-        return this.get(`/human-review/jobs/${jobId}/test-cases`);
+        return this.get(`/human-review/jobs/${encodeURIComponent(jobId)}/test-cases`);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async getHumanReviewJobTestCases(
jobId: string,
): Promise<HumanReviewJobWithTestCases> {
return this.get(`/human-review/jobs/${jobId}/test-cases`);
}
public async getHumanReviewJobTestCases(
jobId: string,
): Promise<HumanReviewJobWithTestCases> {
return this.get(`/human-review/jobs/${encodeURIComponent(jobId)}/test-cases`);
}

src/client.ts Outdated
Comment on lines 242 to 247
public async getHumanReviewJobTestCaseResult(
jobId: string,
testCaseId: string,
): Promise<HumanReviewJobTestCaseResult> {
return this.get(`/human-review/jobs/${jobId}/test-cases/${testCaseId}`);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper encoding of jobId and testCaseId in URL

In getHumanReviewJobTestCaseResult, to prevent issues with special characters in jobId and testCaseId, consider encoding these parameters when constructing the URL.

Apply this diff to encode the parameters:

-        return this.get(`/human-review/jobs/${jobId}/test-cases/${testCaseId}`);
+        return this.get(`/human-review/jobs/${encodeURIComponent(jobId)}/test-cases/${encodeURIComponent(testCaseId)}`);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async getHumanReviewJobTestCaseResult(
jobId: string,
testCaseId: string,
): Promise<HumanReviewJobTestCaseResult> {
return this.get(`/human-review/jobs/${jobId}/test-cases/${testCaseId}`);
}
public async getHumanReviewJobTestCaseResult(
jobId: string,
testCaseId: string,
): Promise<HumanReviewJobTestCaseResult> {
return this.get(`/human-review/jobs/${encodeURIComponent(jobId)}/test-cases/${encodeURIComponent(testCaseId)}`);
}

@adamnolte adamnolte merged commit a48a622 into main Sep 22, 2024
4 checks passed
@adamnolte adamnolte deleted the adam/epd-1397-update-js-sdk branch September 22, 2024 22:09
@coderabbitai coderabbitai bot mentioned this pull request Sep 23, 2024
@coderabbitai coderabbitai bot mentioned this pull request Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants